const mongoose = require("mongoose");
const config = require("../config");
const { UserSchema } = require("./user");
// 注册
let connection = mongoose.createConnection(config.dbUrl, {
  useNewUrlParser: true,
  useUnifiedTopology: true,
});
connection.on('connected',function(err){
  if(err)return console.log('用户数据库连接失败')
  else console.log('用户数据库连接成功')
})
// 连接数据库
var mysql  = require('mysql');  

var sqlConnect = mysql.createConnection({     
  host     : 'localhost',       
  user     : 'root',              
  password : '123456',       
  port: '3306',                   
  database: 'ss_airline' 
}); 
sqlConnect.connect()
console.log('航空公司数据库连接成功')
const UserModel = connection.model("User", UserSchema);
module.exports = {
  UserModel,
  sqlConnect
};
